﻿package org.ccams.dao;

import java.util.List;

import org.ccams.domain.TpInDetail;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class TpInDetailDAO extends SqlMapClientDaoSupport{

	/**
	 * 返回所有记录
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public  List<TpInDetail> getTpindetailAll(){		
		return getSqlMapClientTemplate().queryForList("tp_in_detail.getTpInDetailAll");
	}
	/**
	 * 根据ID返回记录
	 * @param id
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public  List<TpInDetail> getTpindetailById(Long id){		
		return getSqlMapClientTemplate().queryForList("tp_in_detail.getTpInDetailById",id);
	}
	/**
	 * 通过Num和Ord返回具体记录
	 * @param tid
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public  TpInDetail getTpindetailByNumAndOrd(TpInDetail tid){		
		return (TpInDetail)getSqlMapClientTemplate().queryForObject("tp_in_detail.getTpInDetailByNumAndOrd",tid);
	}
	/**
	 * 返回记录行数
	 * @return
	 */
	public Integer getCount(){
		return (Integer)getSqlMapClientTemplate().queryForObject("tp_in_detail.getTpInDetailCount");
	}
	/**
	 * 插入数据
	 * @param tid
	 * @return
	 */
	public int insertTpindetail(TpInDetail tid) {
		return getSqlMapClientTemplate().update("tp_in_detail.insertTpindetail",tid);
	}
	/**
	 * 取得最新插入的数据行的ord
	 * @return
	 */
	public Integer getNewOrd(Long num){
		try{
			return (Integer)getSqlMapClientTemplate().queryForObject("tp_in_detail.getNewOrd",num)+1;
		}catch(NullPointerException e){
			e.printStackTrace();
			return 0;
		}
	}
	/**
	 * 更新数据
	 * @param tid
	 * @return
	 */
	public int updateTpindetail(TpInDetail tid){
		return getSqlMapClientTemplate().update("tp_in_detail.updateTpindetail",tid);
	}
	/**
	 * 删除数据
	 * @param tid
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public int deleteTpindetail(TpInDetail tid){
		return getSqlMapClientTemplate().delete("tp_in_detail.deleteTpindetail",tid);
	}
	/**
	 * 更新审核
	 * @param tid
	 * @return
	 */
	public int updateCommit(TpInDetail tid){
		return getSqlMapClientTemplate().update("tp_in_detail.updateCommit",tid);
	}
	
	
}
